#include <bits/stdc++.h>
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
using namespace std;
typedef long long LL;
const int N = 1e5+5;
int n, x, A, B, u, v, dp[10][2][(1<<8)+5], ddd[10][(1<<8)+5], 
a[N], sum[N], cnt;
vector <int> to[N];
struct qwq {
	int x, y;
};
vector <qwq> tt[N], pp[N];
struct tree {
	int tr[N<<2];
	#define ls (k<<1)
	#define rs (ls|1)
	void built(int k, int l, int r) {
		if(l == r) {
			tr[k]=a[l];
			return ;
		}
		int mid = ((l+r)>>1);
		built(ls, l, mid);
		built(rs, mid+1, r);
		tr[k]=min(tr[ls], tr[rs]);
	}
	int ask(int k, int l, int r, int lq, int rq) {
		if(lq <= l && r <= rq)
			return tr[k];
		int mid = ((l+r)>>1), ret = n;
		if(lq <= mid)
			ret=min(ret, ask(ls, l, mid, lq, rq));
		if(mid < rq)
			ret=min(ret, ask(rs, mid+1, r, lq, rq));
		return ret;
	}
	#undef ls
	#undef rs
}AA;

template <typename T> inline void debug(T x) { cerr<<x; }
template <typename T, typename ...T_> inline void debug(T x, T_ ...p) { cerr<<x<<' ', debug(p...); }
template <typename T> void read(T& x) {
	x = 0; int f = 0; char c = getchar();
	while(c < '0' || c > '9') f |= (c == '-'), c=getchar();
	while(c >= '0' && c <= '9') x=(x<<1)+(x<<3)+(c^48), c=getchar();
	x=(f ? -x : x);
}
int lne; char put[105];
template <typename T> void write(T x, char ch) {
	lne = 0; if(x < 0) putchar('-'), x=-x;
	do { put[++lne]=x%10, x/=10; } while(x);
	while(lne) putchar(put[lne--]^48);
	putchar(ch);
}
int dddfs(int x, int ls, int dep, int s);
int sol(int x, int xh, int s); 
void ddfs(int x, int fa, int dep, int s, int gf) {
	if(dep == A) {
		pp[gf].push_back(qwq {s, x});
		return ;
	}
	for(qwq y : tt[x])
		if(y.x != fa)
			ddfs(y.x, x, dep+1, (s|(1<<y.y)), gf);
}
void dfs(int x, int fa, int dep, int s, int gf) {
	ddd[gf][s]=min(ddd[gf][s], x);
	if(dep == B) return ;
	for(qwq y : tt[x])
		if(y.x != fa && !((s>>y.y)&1))
			dfs(y.x, x, dep+1, s, gf);
}
void sss(int x, int fa) {
	a[++cnt]=x;
	for(int y : to[x])
		if(y != fa)
			sss(y, x);
}

signed main() {
	File("nim");
	read(n), read(x), read(A), read(B);
	if(B >= A) {
		// debug("!!!\n");
		puts("1");
		return 0;
	}
	if(n <= 9) {
		for(int i = 1; i < n; ++i)
			read(u), read(v), tt[u].push_back(qwq {v, i-1}), tt[v].push_back(qwq {u, i-1});
		for(int i = 1; i <= n; ++i) {
			ddfs(i, 0, 0, 0, i);
			for(int j = 0; j < (1<<(n-1)); ++j)
				ddd[i][j]=i, dfs(i, 0, 0, j, i);
		}
		write(sol(x, 1, 0), '\n');
		return 0;
	}
	for(int i = 1; i < n; ++i) 
		read(u), read(v), to[u].push_back(v), to[v].push_back(u);
	sss(x, 0);
	AA.built(1, 1, n);
	for(int l = 1, r = 1; l <= n; ) {
		++sum[l], --sum[r+1];
		l+=A, r=min(r+A+B, n);
	}
	for(int i = 1; i <= n; ++i)
		sum[i]+=sum[i-1];
	int ans = n;
	for(int i = 1; i <= n; ++i)
		if(sum[i]) {
			if(i != 1)
				ans=min(ans, AA.ask(1, 1, n, max(1, i-B), i-1));
			if(i+A > n)
				ans=min(ans, AA.ask(1, 1, n, i, min(i+B, n)));
		}
	write(ans, '\n');
	return 0;
}
int dddfs(int x, int ls, int dep, int s) {
	int ret = sol(x, 1, s);
	if(dep == B) return ret;
	for(qwq y : tt[x])
		if(y.x != ls)
			ret=min(ret, dddfs(y.x, x, dep+1, (s|(1<<y.y))));
	return ret;
}
int sol(int x, int xh, int s) {
	if(dp[x][xh][s]) return dp[x][xh][s];
	if(xh) {
		int ss = 0;
		for(qwq i : pp[x])
			if(!(s&i.x))
				++ss, dp[x][xh][s]=max(dp[x][xh][s], sol(i.y, xh^1, (s|i.x)));
		if(!ss)
			dp[x][xh][s]=ddd[x][s];
	}
	else 
		dp[x][xh][s]=dddfs(x, 0, 0, s);
	return dp[x][xh][s];
}